package com.sicau.smarttraceplatform.utils.upload;

import lombok.Data;

/**
 * @author xiongtao29
 * @title: ExcelCheckErrDto
 * @description: excel单条数据导入失败结果模型
 * @date 2020/3/24
 */
@Data
public class ExcelCheckErrDto<T> {

    private T t;

    /**
     * 正常的errMsg以 ; 分隔
     */
    private String errMsg;

    private Integer row;

    private String col;

    public ExcelCheckErrDto() {

    }

    public ExcelCheckErrDto(T t) {
        this.t = t;
    }

    public ExcelCheckErrDto(T t, String errMsg) {
        this.t = t;
        this.errMsg = errMsg;
    }

    public ExcelCheckErrDto(T t, String errMsg, Integer row, String col) {
        this.t = t;
        this.errMsg = errMsg;
        this.row = row;
        this.col = col;
    }

    public void setErrMsg(String errMsg) {
        if (this.errMsg == null) {
            this.errMsg = "";
        }
        this.errMsg += errMsg + ";";
    }

    public String getErrMsg() {
        if (this.errMsg.endsWith(";")) {
            this.errMsg = this.errMsg.substring(0, this.errMsg.length() - 1);
        }
        return errMsg;
    }
}
